﻿<cfsilent>
	<cfscript>
		
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		jsonAdvice = getProperty("serviceFactory").getBean("jsonAdvice");
		stringAdvice = getProperty("serviceFactory").getBean("stringAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		securityAdvice = getProperty("serviceFactory").getBean("securityAdvice");
		
		response = structNew();
		
		structInsert(response, "success", false, true);
		
		messageId = event.getArg("msgId");
		messageReply = event.getArg("REPLY");

		currentDateTime =  dateCreate = dateFormat(now(),"YYYY-MM-DD") & " " & timeFormat(now(), "HH:MM:SS");
		ip = securityAdvice.getIP();
			
		 transaction {
			 
			 sql = "UPDATE t_message 
					 SET 
						 re_content = :content, 
						 re_time = :reTime, 
						 target_ip = :ip,
						 user_state = '0'  
					 WHERE 
						 id = :messageId ";
			 
			 queryObj = new Query( datasource=application.dnsMaster );
			 
			 queryObj.addParam( name="messageId", value=messageId, cfsqltype="cf_sql_integer" );
			 queryObj.addParam( name="reTime", value=currentDateTime, cfsqltype="cf_sql_varchar" );
			  queryObj.addParam( name="ip", value=ip, cfsqltype="cf_sql_varchar" );
			 queryObj.addParam( name="content", value=messageReply, cfsqltype="cf_sql_varchar" );
			 
			 queryObj.execute( sql=sql );
			 
		 }

			structInsert(response, "success", true, true);
			structInsert(response, "messageId", messageId, true);
			structInsert(response, "messageReply", stringAdvice.HTMLEncode( messageReply ), true);
			structInsert(response, "messageDate", currentDateTime, true);


		
	</cfscript>
</cfsilent><cfoutput>#jsonAdvice.encode(data:response, stringNumbers:true)#</cfoutput>